fix(core): preserve global model config with custom clients - #3094
Draft
linhongyu510 wants to merge 4 commits into
Draft
fix(core): preserve global model config with custom clients#3094linhongyu510 wants to merge 4 commits into
linhongyu510 wants to merge 4 commits into
Conversation
linhongyu510
force-pushed
the
fix/create-openai-client-global-config
branch
from
September 4, 2026 13:25
916fc1b to
a9e0210
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
createOpenAIClientis provided without an explicitmodelConfigagent.modelConfigManager, including Playground describe and locate runtimesRoot cause
AgenttreatedcreateOpenAIClientalone as a custom model configuration and created an isolatedModelConfigManager. Because that manager had neither an explicitmodelConfignor a registeredGlobalConfigManager, it resolved an empty configuration and reported thatMIDSCENE_MODEL_NAMEwas missing.Simply reusing the global manager would fix model resolution but would drop the agent-scoped factory from public
modelConfigManagerconsumers. Playground builds describe and locate runtimes through that public manager, so observability wrappers such as LangSmith or Langfuse would be silently skipped on those paths.Solution
Factory-only agents now use an
AgentScopedModelConfigManagerthat delegates model values toglobalModelConfigManagerand returns a copied configuration with the current agent'screateOpenAIClient.This keeps global overrides and environment updates dynamic, avoids mutating shared cached configurations, and preserves independent factories for multiple agents.
Tests use stubbed environment variables with explicit cache clearing so global configuration state is restored after every case.
Validation
pnpm --filter @midscene/core testpnpm buildpnpm type-check:testspnpm run lintCloses #3079.